#!/bin/sh

./kill.sh

svr_crt="cloud.cert.pem"
svr_key="cloud.prikey.pem"
pub_crt="cloud.cert.der"

# generate private key and certificate for server
if [ ! -e $svr_crt ] || [ ! -e $svr_key ]; then
    openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
        -keyout $svr_key -out $svr_crt \
        -subj \
        "/C=CN/ST=Jiangsu/L=Changzhou/O=Jiangsu Unversity of Technology/OU=JSUT/CN=JSUT/emailAddress=yyx_dev@yeah.net"
fi

# generate public certificate for bowser
if [ ! -e $pub_crt ]; then
    openssl x509 -outform der -in $svr_crt -out $pub_crt 
fi

# openssl genrsa -out server.key 2048
# openssl req -new -x509 -key server.key -out server.crt -days 3650  

# openssl x509 -text -in server.crt
# openssl x509 -in server.crt -noout -dates

make clean
make bin
make pub_aim
make install
